home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1998 September
/
Macworld (1998-09).dmg
/
Shareware World
/
Info
/
For Developers
/
MacZoop 1.8.3
/
More Classes
/
Streaming Classes
/
ZClassRegistry.h
< prev
next >
Wrap
Text File
|
1998-06-12
|
2KB
|
85 lines
/*************************************************************************************************
*
*
* MacZoop - "the framework for the rest of us"
*
*
*
* ZClassRegistry.h -- registry of classes used for persistent objects
*
*
*
*
*
* © 1998, Graham Cox
*
*
*
*
*************************************************************************************************/
#pragma once
#ifndef __ZCLASSREGISTRY__
#define __ZCLASSREGISTRY__
#include "ZArray.h"
#include "ZObject.h"
class ZStream;
typedef struct
{
OSType classid;
ConstructorFunction newfunc;
Str31 classname;
}
Object_Info;
class ZClassRegistry : public ZArray
{
public:
ZClassRegistry();
virtual ~ZClassRegistry();
virtual void RegisterClass( OSType aType, ConstructorFunction aFunc, Str255 aName );
virtual void GetNameOfClass( OSType aType, Str31 aName );
virtual ZObject* InstantiateClass( OSType aType );
virtual ZObject* InstantiateClass( Str31 aName );
virtual long FindClass( OSType aType );
virtual long FindClass( Str31 aName );
// for simplicity and convenience, the object reanimator method is put here- we don't need
// another class for it. This returns the root object built from the stream, and any other
// objects it creates along the way as data members or globals.
virtual ZObject* InstantiateFromStream( ZStream* aStream );
};
// errors:
enum
{
kClassTypeUnknownErr = 601,
kClassNameUnknownErr,
kBadConstructorFuncErr
};
// handy macro for hiding nasty details of registering a class
#define REGISTERCLASS( x ) gClasses->RegisterClass( CLASSID( x ), CONSTRUCTORFUNCTION( x ), CLASSNAME( x ))
#endif